/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jobportal.admin;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jobportal.Dbconn;

/**
 *
 * @author project
 */
public class FeedBack extends HttpServlet {
   
   @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        doPost(request, response);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    PrintWriter out=response.getWriter();
        try {
            Connection con = Dbconn.getConn();
            Statement st = con.createStatement();
            RequestDispatcher rd=request.getRequestDispatcher("feedback.jsp");
            ResultSet rs;
            String sql;
            String name = request.getParameter("name");
            String email = request.getParameter("email");
            String mobile=request.getParameter("mobile");
            String message=request.getParameter("message");

            sql="insert into feedback(name,email,mobile,message) values('"+name+"','"+email+"','"+mobile+"','"+message+"')";
            if(st.executeUpdate(sql)>0){
                request.setAttribute("msg","<strong><font color=green>Successfully Sent </font></stronmg>" );
                rd.forward(request, response);
            }
            else{
                request.setAttribute("msg","<strong><font color=red>Feedback Sending Failed</font></stronmg>" );
                rd.forward(request, response);
                
            }
        }catch(Exception e){
            out.println("Exception::"+e);
        }

    }
}
